let readlineSync = require('readline-sync');
let match = require('./main');

//获取用户输入值
let userNum = readlineSync.question('Please input a number!\n');

//随机生成四个不重复的数字
//从一个给定的数组limit中,随机返回4个不重复项,以此保证不重复
function getRandomNum() {
    let limit=[];
    for(let i=0;i<10;i++){
        limit.push(i);
    }
    let randomNumArr=[];
    for(let i=0;i<4;i++){
        let index = Math.floor( Math.random()*limit.length );
        randomNumArr.push(limit[index]);
        limit.splice(index,1);
    }
    let randomNum = randomNumArr.join("");
    return randomNum;
}
let randomNum = getRandomNum();
console.log(`The randomNum is ${randomNum}`);

console.log(match(userNum, randomNum));